var CANVAS_WIDTH = 500 ,CANVAS_HEIGHT = 500;    //画布要调大一点
/* 创建对象 */
var mycanvas,context;
window.onload = function (){
    createCanvas();
    drawRect();
}
/* 创建canvas的方法 */
function createCanvas(){
    document.body.innerHTML = "<canvas id=\"mycanvas\" width=\""+CANVAS_WIDTH+"\" height=\""+CANVAS_HEIGHT+"\"></canvas>";
    mycanvas = document.getElementById("mycanvas");
    context = mycanvas.getContext("2d");
}
/* 绘制图形的方法 */
function drawRect(){
    context.fillStyle="#ff0000";
    // context.rotate(45);  //旋转45°
    // context.translate(200,200);  //x,y
    context.scale(2,0.5);  //x,y
    context.fillRect(0,0,200,200);  //x,y

}